package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Println("-----------------------------------------------")
	file, err := os.OpenFile("./hello.txt", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666)
	defer func(file *os.File) {
		err := file.Close()
		if err != nil {
			fmt.Println(err)
		}
	}(file)
	if err != nil {
		fmt.Println(err)
		return
	}
	bytes := []byte("hello world\r\n")
	_, err = file.Write(bytes)
	//_, err = file.WriteString("陈浩杰\r\n")
	if err != nil {
		fmt.Println(err)
		return
	}
}
